@extends('layouts.admin.application')

@section('content')
    <div class="main-content">
        <div class="col-xs-12">
            <div class="breadcrumbs" id="breadcrumbs">
                <ul class="breadcrumb">
                    <li><i class="icon-home home-icon"></i><a href="#">首页</a></li>
                    <li><a href="{{ route('system.role.index') }}">用户组管理</a></li>
                    <li class="active">新增用户组</li>
                </ul>
            </div>

            @include('layouts.partials._flash')

            <form class="form-horizontal" role="form" action="{{ route('system.role.store') }}" method="post"
                  style="margin-top: 20px;">

                {{csrf_field()}}

                <div class="form-group">
                    <label class="col-sm-4 col-md-2 control-label no-padding-right">用户组名：</label>

                    <div class="col-sm-8 col-md-4 col-end">
                        <input type="text" name="name" placeholder="请输入用户组名" class="input-sm">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-4 col-md-2 control-label no-padding-right">权限列表：</label>

                    <div class="col-sm-8 col-md-8 col-end">

                        @foreach($permissions as $permission)
                            <div class="panel panel-default menu_panel">
                                <div class="panel-hd">
                                    <label class="checkbox-inline">
                                        <input type="checkbox" value="{{$permission->id}}" name="permission_id[]"
                                               class="permission1">
                                        <span class="badge badge-info text-sm radius">{{$permission->label}}</span>
                                    </label>
                                </div>
                                <div class="panel-bd">

                                    @foreach($permission->children as $child)
                                        <div>
                                            <div class="col-sm-4 col-sm-3 col-end">
                                                <label class="checkbox-inline">
                                                    <input type="checkbox" value="{{$child->id}}" name="permission_id[]"
                                                           class="permission2">
                                                    <span class="badge badge-success radius">{{$child->label}}</span>
                                                </label>
                                            </div>
                                            <div class="col-sm-8 col-sm-9 col-end">

                                                @foreach($child->children as $c)
                                                    <label class="checkbox-inline">
                                                        <input type="checkbox" value="{{$c->id}}" name="permission_id[]">{{$c->label}}
                                                    </label>
                                                @endforeach

                                            </div>
                                        </div>
                                    @endforeach
                                </div>
                            </div>
                        @endforeach
                    </div>
                </div>


                <div class="clearfix form-actions">
                    <div class="col-md-offset-3 col-md-9">
                        <button class="btn btn-info" type="submit"><i class="icon-ok bigger-110"></i>保存</button>
                        &nbsp; &nbsp; &nbsp;
                        <a class="btn" onclick="javascript:history.back(-1);return false;">
                            <i class="icon-undo bigger-110"></i>返回</a>
                    </div>
                </div>
            </form>
        </div>

    </div>
@endsection

